﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;



namespace Proyecta.Perfiles
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            cargarDatos();
        }

        public void cargarDatos()
        {
            DataSet ds = null;
            Proyecta.Data.BO.PermisosBO oPer = new Data.BO.PermisosBO();
            Proyecta.Data.DAO.PermisosDAO daoPer = new Data.DAO.PermisosDAO();

            ds = daoPer.Mostrar(oPer);
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            GridView1.DataBind();
        }

        protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            e.Cancel = true;
            GridView1.EditIndex = -1;
            GridView1.DataBind();
        }

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Proyecta.Data.BO.PermisosBO operbo = new Data.BO.PermisosBO();
            GridViewRow row = GridView1.Rows[e.RowIndex];

            operbo.idPermiso = ((TextBox)(row.Cells[1].Controls[0])).Text;
            //operbo.Nombre = ((TextBox)(row.Cells[2].Controls[0])).Text;
            GridView1.EditIndex = -1;
            GridView1.DataBind();
            Response.Redirect("Perfiles.aspx?id="+operbo.idPermiso+"");
            
            

        }

        protected void btnNuevo_Click(object sender, EventArgs e)
        {
            Response.Redirect("Perfiles.aspx");
        }

    }
}